Next | Prev | Up | Top | Contents | Index

How Devices Are Defined

When a device special file is created in the /dev file system, it is associated with the device driver that will manage it. The connection between the device name and the device driver is made through major and minor device numbers, which are recorded with the device name in the file system. To see these numbers, try a command such as

ls -l /dev/dsk

Device creation is documented in the system(4) reference page, the makedev(1), mknod(1), and install(1) reference pages, and in the /dev/MAKEDEV script. Device administration is covered in detail in IRIX Admin: System Configuration and Operation (see "Other Useful Books" on page xxiii).

The major device number selects the device driver. The minor number is passed to the device driver each time it is entered; it encodes such useful parameters as logical unit number or density. In some cases, a device is represented by more than one name in the /dev hierarchy. This associates it with more than one device driver, or else causes the device driver to treat the device differently depending on the minor number that is passed.

For example, a disk device can appear in both the /dev/dsk and the /dev/rdsk directories, and the same disk can appear under several names in each directory, with each name standing for a different partition of the disk. (The naming of disk devices is documented in the dksc(7) reference page.) Again, a tape drive usually appears multiple times in /dev/mt, with each name receiving different treatment from the tape device driver--names containing "ns," for example, are written with integers in non-byte-swapped order for compatibility with other systems.


Next | Prev | Up | Top | Contents | Index